<template>
  <div class="milk-header">
    <div class="page-name f-y-center">
      <div style="font-family: 'hey_elsie_cuteregular'">
<!--        <span style="font-size: 24px">&#45;&#45; </span>-->
        <span style="font-size:30px;color:#c2a6fa">D</span>
        <span style="font-size:22px;color:#ffa0d1">a</span>
        <span style="font-size:24px;color:rgba(255, 213, 221, 0.65)">i</span>
        <span style="font-size:22px;color:#a6bfff">s</span>
        <span style="font-size:28px;color:#ffdf9e">y</span>
<!--        <span style="font-size: 24px"> &#45;&#45;</span>-->
        </div>
    </div>
    <div
        class="burger"
        :class="{'transform':rightTopBtn}"
        @click.stop="rightTopBtn=!rightTopBtn"
    >
      <div></div>
      <div></div>
      <div></div>
      <section @click.stop="rightTopBtn=false" v-if="rightTopBtn" class="milk-dropdown">
        <simple-nav :value="navList"></simple-nav>
      </section>
    </div>
  </div>
</template>

<script>
import SimpleNav from '../nav/NavSimple'
import constant from '../../libs/constant'

export default {
  name: 'MilkHeader',
  components: { SimpleNav },
  data () {
    return {
      navList: constant.nav,
      pageName: '首页',
      rightTopBtn: false
    }
  },
  watch: {
    '$route': {
      handler (to, from) {
        if (to.meta && to.meta.title) {
          this.pageName = to.meta.title
        } else {
          this.pageName = 'Blossom~'
        }
      },
      immediate: true
    }
  },
  mounted () {
    document.body.addEventListener('click', () => {
      this.rightTopBtn = false
    })
  }
}
</script>

<style>
.milk-header {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55px;
  padding: 8px;
  background-color: #FFFFFF;
  z-index: 99;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
}

.page-name {
  flex: 1;
  justify-content: center;
  font-size: 16px;
  font-weight: 400;
  padding-left: 14px;
  color: #7c7a7e;
}

/* 按钮容器 START */
.burger {
  position: relative;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: inline-block;
  margin: 7px 6px 0 auto;
  outline: none;
}

/* 按钮容器 END */

/* 三条横线 通过rotate3d实现旋转 START */
.burger div {
  width: 18px;
  height: 2px;
  margin-bottom: 4px;
  background-color: rgb(118, 114, 114);
  transform: rotate3d(0, 0, 0, 0);
}

/* 三条横线 END */

.burger.transform div {
  background-color: transparent;
}

.burger.transform div:first-of-type {
  top: 6px;
  transform: rotate3d(0, 0, 1, 45deg)
}

.burger.transform div:last-of-type {
  bottom: 6px;
  transform: rotate3d(0, 0, 1, -45deg)
}

/* 点击后第一个和第三个横线的效果 START */
.burger.transform div:first-of-type, .burger.transform div:last-of-type {
  transition: transform .4s .3s ease, background-color 250ms ease-in;
  background: #a175ed;
}

/* 点击后第一个和第三个横线的效果 END */

/* 取消点击后恢复动画 START */
.burger div:first-of-type, .burger div:last-of-type {
  transition: transform .3s ease .0s, background-color 0ms ease-out;
  position: relative;
}

/* 取消点击后恢复动画 END */

.milk-dropdown {
  position: absolute;
  padding: 20px 14px;
  background-color: white;
  /*box-shadow: 0 0 5rem 1rem rgba(148, 148, 148, 0.4);*/
  box-shadow: 0 11px 15px -7px rgba(0, 0, 0, .2), 0 24px 38px 3px rgba(0, 0, 0, .14), 0 9px 46px 8px rgba(0, 0, 0, .12);
  border-radius: 8px;
  height: 300px;
  width: 180px;
  top: 40px;
  right: 0;
  overflow: auto;
  z-index: 9999;
}

/*992px以内*/
@media (max-width: 992px) {
  .milk-header {
    display: flex;
    align-items: center;
    justify-content: space-around;
  }
}
</style>
